package pers.leeyns.rd.tel;

import pers.leeyns.rd.base.BaseRandom;

/**
 * @description 座机号码 或者 手机号随机生成
 * @author Leeyns
 * @date 2016年2月16日
 */
public class RandomTelGenerator extends BaseRandom{

	/**
	 * 
	 */
	private static final long serialVersionUID = -9168311902586014649L;
	public static synchronized RandomTelGenerator build(){
		return new RandomTelGenerator();
	}
	
	public RandomTelGenerator(){
		loadTellSerialNumbers();
	}
	
	private void loadTellSerialNumbers(){
		TELL_SERIAL_NUMBERS = new String[TELL_SERIAL_NUMBERS_MODEL.length];
		for(int i = 0;i< TELL_SERIAL_NUMBERS_MODEL.length;i++){
			String serial = TELL_SERIAL_NUMBERS_MODEL[i];
			if(serial.contains(":")){
				TELL_SERIAL_NUMBERS[i] = serial.split("[:]")[1];
			}
		}
	}
	
	
	/**
	 * 随机生成座机号码
	 * @return
	 */
	public String getRandomTel(){
		return TELL_SERIAL_NUMBERS[this.nextInt(TELL_SERIAL_NUMBERS.length)]+getRandomTelSubfix(7);
	}
	
	/**
	 * 随机生成手机号码
	 * @return
	 */
	public String getRandomCellPhoneNumber(){
		return CELLPHONE_PREFIX[nextInt(CELLPHONE_PREFIX.length)] + getRandomTelSubfix(8);
	}
	
	private String getRandomTelSubfix(int len){
		StringBuffer sbf = new StringBuffer();
		for(int i = 0;i < len;i++){
			sbf.append(this.getRandomNumber(new int[]{0,1,2,3,4,5,7,6,8,9})+"");
		}
		return sbf.toString() ;
	}
	public static void main(String[] args) {
		RandomTelGenerator r = RandomTelGenerator.build();
		while(true){
//			System.out.println(r.getRandomTel("-"));
			System.out.println(r.getRandomCellPhoneNumber());
		}
	}
	
	
	
	
	
	private static  String [] TELL_SERIAL_NUMBERS = null;
	
	
	/**
	 *cell phone prefix 
	 */
	private static final String [] CELLPHONE_PREFIX = "134,135,136,137,138,139,150,151,152,157,158,159,130,131,132,155,156,133,153".split(",");
	/**
	 * 电话区号
	 */
	private static final String [] TELL_SERIAL_NUMBERS_MODEL = {"北京:010","上海:021","天津:022","重庆:023","内蒙古>呼伦贝尔:0470",
	"内蒙古>巴彦淖尔:0478","内蒙古>乌兰察布:0474","内蒙古>兴安盟:0482","内蒙古>锡林郭勒:0479","内蒙古>阿拉善盟:0483","辽宁省>沈阳:024",
	"辽宁省>大连:0411","辽宁省>鞍山:0412","辽宁省>抚顺:0413","辽宁省>本溪:0414","辽宁省>丹东:0415","辽宁省>锦州:0416","辽宁省>营口:0417",
	"辽宁省>阜新:0418","辽宁省>辽阳:0419","辽宁省>盘锦:0427","辽宁省>铁岭:0410","辽宁省>朝阳:0421","辽宁省>葫芦岛:0429","吉林省>长春:0431",
	"吉林省>吉林:0432","吉林省>四平:0434","吉林省>辽源:0437","吉林省>通化:0435","吉林省>白山:0439","吉林省>松原:0438",
	"吉林省>白城:0436","吉林省>延边:0433","黑龙江>哈尔滨:0451","黑龙江>齐齐哈尔:0452","黑龙江>鸡西:0467","黑龙江>鹤岗:0468",
	"黑龙江>双鸭山:0469","黑龙江>大庆:0459","黑龙江>伊春:0458","黑龙江>佳木斯:0454","黑龙江>七台河:0464","黑龙江>牡丹江:0453",
	"黑龙江>黑河:0456","黑龙江>绥化:0455","黑龙江>大兴安岭:0457","江苏省>南京:025","江苏省>无锡:0510","江苏省>徐州:0516",
	"江苏省>常州:0519","江苏省>苏州:0512","江苏省>南通:0513","江苏省>连云港:0518","江苏省>淮安:0517","江苏省>盐城:0515",
	"江苏省>扬州:0514","江苏省>镇江:0511","江苏省>泰州:0523","江苏省>宿迁:0527","浙江省>杭州:0571","浙江省>宁波:0574",
	"浙江省>温州:0577","浙江省>嘉兴:0573","浙江省>湖州:0572","浙江省>绍兴:0575","浙江省>金华:0579","浙江省>衢州:0570",
	"浙江省>舟山:0580","浙江省>台州:0576","浙江省>丽水:0578","安徽省>合肥:0551","安徽省>芜湖:0553","安徽省>蚌埠:0552","安徽省>淮南:0554",
	"安徽省>马鞍山:0555","安徽省>淮北:0561","安徽省>铜陵:0562","安徽省>安庆:0556","安徽省>黄山:0559","安徽省>滁州:0550","安徽省>阜阳:0558",
	"安徽省>宿州:0557","安徽省>巢湖:0565","安徽省>六安:0564","安徽省>亳州:0558","安徽省>池州:0566","安徽省>宣城:0563","福建省>福州:0591",
	"福建省>厦门:0592","福建省>莆田:0594","福建省>三明:0598","福建省>泉州:0595","福建省>漳州:0596","福建省>南平:0599","福建省>龙岩:0597",
	"福建省>宁德:0593","江西省>南昌:0791","江西省>景德镇:0798","江西省>萍乡:0799","江西省>九江:0792","江西省>新余:0790","江西省>鹰潭:0701",
	"江西省>赣州:0797","江西省>吉安:0796","江西省>宜春:0795","江西省>抚州:0794","江西省>上饶:0793","山东省>济南:0531","山东省>青岛:0532",
	"山东省>淄博:0533","山东省>枣庄:0632","山东省>东营:0546","山东省>烟台:0535","山东省>潍坊:0536","山东省>济宁:0537","山东省>泰安:0538",
	"山东省>威海:0631","山东省>日照:0633","山东省>莱芜:0634","山东省>临沂:0539","山东省>德州:0534","山东省>聊城:0635","山东省>滨州:0543",
	"山东省>菏泽:0530","河南省>郑州:0371","河南省>开封:0378","河南省>洛阳:0379","河南省>平顶山:0375","河南省>安阳:0372","河南省>鹤壁:0392",
	"河南省>新乡:0373","河南省>焦作:0391","河南省>濮阳:0393","河南省>许昌:0374","河南省>漯河:0395","河南省>三门峡:0398","河南省>南阳:0377",
	"河南省>商丘:0370","河南省>信阳:0376","河南省>周口:0394","河南省>驻马店:0396","河南省>济源:0391","湖北省>武汉:027","湖北省>黄石:0714",
	"湖北省>十堰:0719","湖北省>宜昌:0717","湖北省>襄阳:0710","湖北省>鄂州:0711","湖北省>荆门:0724","湖北省>孝感:0712","湖北省>荆州:0716",
	"湖北省>黄冈:0713","湖北省>咸宁:0715","湖北省>随州:0722","湖北省>恩施:0718","湖北省>仙桃:0728","湖北省>潜江:0728","湖北省>天门:0728",
	"湖北省>神农架:0719","湖南省>长沙:0731","湖南省>株洲:0733","湖南省>湘潭:0732","湖南省>衡阳:0734","湖南省>邵阳:0739","湖南省>岳阳:0730",
	"湖南省>常德:0736","湖南省>张家界:0744","湖南省>益阳:0737","湖南省>郴州:0735","湖南省>永州:0746","湖南省>怀化:0745","湖南省>娄底:0738",
	"湖南省>湘西:0743","广东省>广州:020","广东省>韶关:0751","广东省>深圳:0755","广东省>珠海:0756","广东省>汕头:0754","广东省>佛山:0757",
	"广东省>江门:0750","广东省>湛江:0759","广东省>茂名:0668","广东省>肇庆:0758","广东省>惠州:0752","广东省>梅州:0753","广东省>汕尾:0660",
	"广东省>河源:0762","广东省>阳江:0662","广东省>清远:0763","广东省>东莞:0769","广东省>中山:0760","广东省>潮州:0768","广东省>揭阳:0663",
	"广东省>云浮:0766","广西>南宁:0771","广西>柳州:0772","广西>桂林:0773","广西>梧州:0774","广西>北海:0779","广西>防城港:0770","广西>钦州:0777",
	"广西>贵港:0775","广西>玉林:0775","广西>百色:0776","广西>贺州:0774","广西>河池:0778","广西>来宾:0772","广西>崇左:0771","海南省>海口:0898",
	"海南省>三亚:0898","海南省>五指山:0898","海南省>琼海:0898","海南省>儋州:0898","海南省>文昌:0898","海南省>万宁:0898","海南省>东方:0898",
	"海南省>定安:0898","海南省>屯昌:0898","海南省>澄迈:0898","海南省>临高:0898","海南省>白沙:0898","海南省>昌江:0898","海南省>乐东:0898",
	"海南省>陵水:0898","海南省>保亭:0898","海南省>琼中:0898","海南省>洋浦:0890","海南省>南沙群岛:0898","海南省>中沙群岛:0898","四川省>成都:028",
	"四川省>自贡:0813","四川省>攀枝花:0812","四川省>泸州:0830","四川省>德阳:0838","四川省>绵阳:0816","四川省>广元:0839","四川省>遂宁:0825",
	"四川省>内江:0832","四川省>乐山:0833","四川省>南充:0817","四川省>眉山:0833","四川省>宜宾:0831","四川省>广安:0826","四川省>达州:0818",
	"四川省>雅安:0835","四川省>巴中:0827","四川省>资阳:0832","四川省>阿坝:0837","四川省>甘孜:0836","四川省>凉山:0834","贵州省>贵阳:0851",
	"贵州省>六盘水:0858","贵州省>遵义:0852","贵州省>安顺:0853","贵州省>铜仁:0856","贵州省>黔西南:0859","贵州省>毕节:0857",
	"贵州省>黔东南:0855","贵州省>黔南:0854","云南省>昆明:0871","云南省>曲靖:0874","云南省>玉溪:0877","云南省>保山:0875",
	"云南省>昭通:0870","云南省>丽江:0888","云南省>普洱:0879","云南省>临沧:0883","云南省>楚雄:0878","云南省>红河:0873",
	"云南省>文山:0876","云南省>西双版纳:0691","云南省>大理:0872","云南省>德宏:0692","云南省>怒江:0886","云南省>迪庆:0887","西藏>拉萨:0891",
	"西藏>昌都:0895","西藏>山南:0893","西藏>日喀则:0892","西藏>那曲地区:0896","西藏>阿里地区:0897","西藏>林芝地区:0894","陕西省>西安:029",
	"陕西省>铜川:0919","陕西省>宝鸡:0917","陕西省>咸阳:029","陕西省>渭南:0913","陕西省>延安:0911","陕西省>汉中:0916","陕西省>榆林:0912",
	"陕西省>安康:0915","陕西省>商洛:0914","甘肃省>兰州:0931","甘肃省>嘉峪关:0937","甘肃省>金昌:0935","甘肃省>白银:0943","甘肃省>天水:0938",
	"甘肃省>武威:0935","甘肃省>张掖:0936","甘肃省>平凉:0933","甘肃省>酒泉:0937","甘肃省>庆阳:0934","甘肃省>定西:0932","甘肃省>陇南:0939",
	"甘肃省>临夏:0930","甘肃省>甘南:0941","青海省>西宁:0971","青海省>海东:0972","青海省>海北:0970","青海省>黄南:0973","青海省>海南:0473",
	"青海省>果洛:0975","青海省>玉树:0976","青海省>海西:0979","宁夏>银川:0951","宁夏>石嘴山:0952","宁夏>吴忠:0953","宁夏>固原:0954",
	"宁夏>中卫:0955","新疆>乌鲁木齐:0991","新疆>克拉玛依:0990","新疆>吐鲁番:0995","新疆>哈密:0902","新疆>昌吉:0994","新疆>博尔塔拉:0909",
	"新疆>巴音郭楞:0996","新疆>阿克苏:0997","新疆>克孜勒苏:0908","新疆>喀什:0998","新疆>和田:0903","新疆>伊犁:0999","新疆>塔城:0901",
	"新疆>阿勒泰:0906","新疆>石河子:0993","新疆>阿拉尔:0997","新疆>图木舒克:0998","新疆>五家渠:0994","河北省>石家庄:0311","河北省>唐山:0315",
	"河北省>秦皇岛:0335","河北省>邯郸:0310","河北省>邢台:0319","河北省>保定:0312","河北省>张家口:0313","河北省>承德:0314","河北省>沧州:0317",
	"河北省>廊坊:0316","河北省>衡水:0318","山西省>太原:0351","山西省>大同:0352","山西省>阳泉:0353","山西省>长治:0355","山西省>晋城:0356",
	"山西省>朔州:0349","山西省>晋中:0354","山西省>运城:0359","山西省>忻州:0350","山西省>临汾:0357","山西省>吕梁:0358","内蒙古>呼和浩特:0471",
	"内蒙古>包头:0472","内蒙古>乌海:0473","内蒙古>赤峰:0476","内蒙古>通辽:0475","内蒙古>鄂尔多斯:0477"};
}
